<form action="{:sysuri()}" method="post" data-auto="true" class="layui-form layui-card" data-table-id="BannerInfo">

    <div class="layui-card-body">

        <div class="layui-form-item">
            <label class="layui-form-label label-required-next">{:Lang("同步仓库")}:</label>
            <div class="layui-input-block">
                <select name="warehouse_id" lay-search class="layui-select" lay-filter="store">

                    {foreach $warehouse_arr as $key => $name}

                    <option value="{$key}" >{$name|default=''}</option>

                    {/foreach}
                </select>

            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label label-required-next">{:Lang("使用渠道")}:</label>
            <div class="layui-input-block">
                <select name="channel_id" lay-search class="layui-select channel"  >
                    <option value=''>-- {:lang('全部')} --</option>

                    {foreach $channel_arr as $key => $name}

                    <option value="{$key}" >{$name|default=''}</option>

                    {/foreach}
                </select>

            </div>
        </div>
    </div>
    <input type="hidden" value="{$order_ids}" name="order_ids">
    <input type="hidden" value="{$shop_id}" name="shop_id">
    <div class="hr-line-dashed" style="margin-top:15px;margin-bottom: 120px "></div>

    <div class="layui-form-item text-center text-bottom">
        <button class="layui-btn" type='submit'>保存数据</button>
        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗？" data-close>取消编辑</button>
    </div>
</form>

<script>

    // 指向元素为 `<select lay-filter="test"></select>` 的选择事件
    form.on('select(store)', function(data){

        $.ajax({
            type : 'get',
            url  : "{:sysuri('common/ajax/getChannelByWarehouse')}",
            data : {warehouse_id:data.value},
            success:function (res) {

                if (res.code == 1) {
                    var html = "<option value=''>{:lang('-- 请选择 --')}</option>";

                    let data = res.data;
                    for (var i in data) {

                        html += "<option value='"+i+"'>"+data[i]+"</option>";
                    }

                    $('.channel').html(html);

                    layui.form.render('select'); // 仅渲染 select 元素
                }
            }
        })
    });


</script>